<?php
$url = 'http://wap.kaboshihaoka.com/';

define('TIME', time());
$pwd = '$2y$10$LTQDFyRFTVznuo73r1VQUO5CMZx5XtRE8GXpgnivp02/H9WzqPnYy';
//echo password_hash('Gzx.123',PASSWORD_DEFAULT);
//echo PHP_EOL;
//echo password_verify('a15960069285',$pwd);
//exit;
//echo sign();
//{"id":7493,"nickname":"卡神","account":"17795133580","level":3,"create_user_id":4606,"order_all_no":0,"order_today_no":0,"order_yest_no":0,"order_active_no":0,"yu_e":0,"status":1,"avatar":null,"note":null,"last_login_ip":"223.104.206.32","last_login_date":"2023-04-13 07:51:46","bank_msg":null,"access_token":null,"callback_url":null,"created_at":"2023-04-10 00:49:22","updated_at":"2023-04-13 07:51:46","ali_msg":null,"poster":null,"user_path":"4606,4604,1"}
function sign()
{
    $config = [
        'secret' => '024e3c701bdb23979a18e039fc4e7dc6',
        'user_id' => '4606',
        'timestamp' => TIME,
        '_secret' => '024e3c701bdb23979a18e039fc4e7dc6',
    ];
    $query = implode('&', $config);
    return md5($query);
}

function get($id){
    $url = 'http://wap.kaboshihaoka.com/api/order/msg/get';
    $query = [
        'agent_id' => $id,
        'timestamp' => TIME,
        'sign' => sign(),
        'per_page' => 50,
        'page' => 1,
        'cus_order_id' => '',
        'order_id' => '',
        'time_start' => '',
        'time_end' => '',
    ];
    $parame = http_build_query($query);
    $url = $url . '?' . $parame;
    $res =  file_get_contents($url);
    echo $res;
//    file_put_contents('get.log',$id."\t".$res."\n",8);
}

function set($id){
    $data = [
        "agent_id" => $id,
        "timestamp" => TIME,
        "sign" => sign(),
        "good_id" => 404,
        "cus_order_id" => "test" . TIME.rand(1000,999),
        "province_code" => "410000",
        "city_code" => "411400",
        "area_code" => "411421",
        "province_name" => "河南省",
        "city_name" => "商丘市",
        "area_name" => "民权县",
        "address" => "大道302号",
        "user_no" => "111111200308031844",
        "username" => "李先生",
        "phone" => "15900000000"
    ];
    $res = make($data);
    file_put_contents('set.log',$id."\t".$res."\n",8);
}


function make($params)
{
    $url = 'http://wap.kaboshihaoka.com/api/order/make';
    $params = http_build_query($params);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);//超时设置6秒
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);//超时设置6秒
    curl_setopt($ch, CURLOPT_HTTPHEADER, ["Accept:application/x-www-form-urlencoded", "Accept-Charset: utf-8"]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
    $response = curl_exec($ch);
    curl_close($ch);
    return $response;

}
get(4606);
//for ($i=100;$i<34000;$i++){
//    get($i);
//    set($i);
//    sleep(1);
//}





